#include<iostream>
#include<string>
using namespace std;
string s;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		cin >> s;
		int ans = n - 1;
		for (int i = 1; i < n - 1; i++) {
			if (s[i - 1] == s[i + 1])ans--;
		}
		cout << ans << endl;
	}
	return 0;
}